const utils           = require('../../../utils');
const BaseHandler     = require('../base-handler');
const HTTP_VERBS      = require('../../../constants').HTTP_VERBS;

class TrialHandler extends BaseHandler {

    get pattern() {
        return "/trial";
    }

    doGET(request, response){

        if (!request.session.user.authenticated) {
            var security_code = utils.uuid();
            this.ensureRef(request);
            request.session.user.security_code = security_code;
            response.render('console/trial', {
                security_code: security_code
            });
        } else {
            response.redirect('/console');
        }
        
    }

    setup() {
        this.registerVerb(HTTP_VERBS.GET, this.doGET);
    }
}

module.exports = TrialHandler;